package com.shop.Interceptor;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
//是否登录拦截
public class PrivilegeInterceptor extends AbstractInterceptor {
	private static final long serialVersionUID = -3769711932414602585L;
	public String intercept(ActionInvocation invocation) throws Exception {
		ActionContext context = invocation.getInvocationContext() ;
		Object username = context.getSession().get("username") ;
		if(username != null) {
			return invocation.invoke() ;
		} else {
			context.put("msg", "未登录，请前往进行登录！") ;
			return Action.LOGIN ;
		}
	}
}